<template>
	<view class="">
		<view>
			<slot name="top"></slot>
		</view>
		<view
				:style="[{ borderRadius: radius + 'rpx', marginBottom: marginBottom + 'rpx' }]"
				class="ss-order-card-warp ss-flex ss-col-stretch ss-row-between bg-img"
		>
			<view class="img-box ss-m-r-24">
				<view
						v-if="publishStatus === 0 && showPublishStatus === true"
						style="
					background-color: #f31000;
          color: #fff;
          font-size: 12px;
          padding: 2px 4px;
          border-radius: 3px;
          position: absolute;
          top: 10px;
          left: 10px;
          font-weight: bold;
				">SOLD
				</view>
				<image :src="sheep.$url.cdn(img)" class="order-img" mode="aspectFill" @click="toDetail(skuString)"></image>
			</view>
			<view
					:style="[{ width: titleWidth ? titleWidth + 'rpx' : '' }]"
					class="box-right ss-flex-col ss-row-between"
			>
				<view v-if="title" class="title-text ss-line-2">{{ title }}</view>
				<view v-if="skuString" class="spec-text ss-m-t-8 ss-m-b-12" @click="toDetail(skuString)">
					{{ skuString }} <span style="color: red">{{ confirmText }}</span>
				</view>
				<view class="groupon-box">
					<slot name="groupon"></slot>
				</view>
				<view class="ss-flex">
					<view class="ss-flex ss-col-center">
						<view
								v-if="price && Number(price) > 0"
								:style="[{ color: priceColor }]"
								class="price-text ss-flex ss-col-center"
						>
							{{ price }}元
							<text v-if="!sheep.$helper.isRealEmpty(jpPrice)">({{ jpPrice }}日元)</text>
						</view>
						<!--            <view v-if="score && Number(price) > 0">+</view>-->
						<!--            <view class="price-text ss-flex ss-col-center" v-if="score">-->
						<!--              <image-->
						<!--                :src="sheep.$url.static('/static/img/shop/goods/score1.svg')"-->
						<!--                class="score-img"-->
						<!--              ></image>-->
						<!--              <view>{{ score }}</view>-->
						<!--            </view>-->
						<!--<view v-if="num" class="total-text ss-flex ss-col-center">
							<text>/ {{ num }}</text>
						</view>-->
						<slot name="priceSuffix"></slot>
					</view>
				</view>
				<view class="tool-box">
					<slot name="tool"></slot>
				</view>
				<view>
					<slot name="rightBottom"></slot>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import sheep from '@/sheep';
import {computed} from 'vue';
import {onLoad} from "@dcloudio/uni-app";

/**
 * 订单卡片
 *
 * @property {String} img                      - 图片
 * @property {String} title                    - 标题
 * @property {Number} titleWidth = 0                - 标题宽度，默认0，单位rpx
 * @property {String} skuText                    - 规格
 * @property {String | Number} price                - 价格
 * @property {String} priceColor                  - 价格颜色
 * @property {Number | String} num                  - 数量
 *
 */
const props = defineProps({
	img: {
		type: String,
		default: 'https://img1.baidu.com/it/u=1601695551,235775011&fm=26&fmt=auto',
	},
	title: {
		type: String,
		default: '',
	},
	confirmText: {
		type: String,
		default: '',
	},
	publishStatus: {
		type: Number,
		default: 1,
	},
	showPublishStatus: {
		type: Boolean,
		default: true,
	},
	titleWidth: {
		type: Number,
		default: 0,
	},
	platformType: {
		type: Number,
		default: 0,
	},
	skuText: {
		type: [String, Array],
		default: '',
	},
	price: {
		type: [String, Number],
		default: '',
	},
	jpPrice: {
		type: [String, Number],
		default: '',
	},
	priceColor: {
		type: [String],
		default: '',
	},
	num: {
		type: [String, Number],
		default: 0,
	},
	pack: {
		type: [String, Number],
		default: 0,
	},
	score: {
		type: [String, Number],
		default: '',
	},
	radius: {
		type: [String],
		default: '',
	},
	marginBottom: {
		type: [String],
		default: '',
	},
});
const skuString = computed(() => {
	if (!props.skuText) {
		return '';
	}
	if (typeof props.skuText === 'object') {
		return props.skuText.join(',');
	}
	return props.skuText;
});
// 复制
const onCopy = (data) => {
	sheep.$helper.copyText(data);
};
const toDetail = (id) => {
	// sheep.$router.go('/pages/goods/index', {id: id})
	if (id.indexOf('YS') > -1) {
		sheep.$router.go('/pages/goods/preIndex', { id: id })
	} else {
		sheep.$router.go('/pages/goods/index', { id: id, platform: props.platformType })
	}
};
</script>

<style lang="scss" scoped>

.bg-img {
	//background-image: url("https://marubuy-oss.oss-cn-beijing.aliyuncs.com/2024/11/038bcffe4c6e7248b8ba71b9ca4aadd03citem_bg.png");
	//background-size: 100% 100%;
	//background-repeat: no-repeat;
}

.score-img {
	width: 36rpx;
	height: 36rpx;
	margin: 0 4rpx;
	border: 2px solid #F39800;
}

.ss-order-card-warp {
	padding: 20rpx;

	.img-box {
		width: 164rpx;
		height: 164rpx;
		border-radius: 10rpx;
		overflow: hidden;

		.order-img {
			width: 164rpx;
			height: 164rpx;
		}
	}

	.box-right {
		flex: 1;
		// width: 500rpx;
		// height: 164rpx;
		position: relative;

		.tool-box {
			position: absolute;
			right: 0rpx;
			bottom: -10rpx;
		}
	}

	.title-text {
		font-size: 28rpx;
		font-weight: 500;
		line-height: 40rpx;
	}

	.spec-text {
		font-size: 24rpx;
		font-weight: bold;
		color: $orange;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
	}

	.price-text {
		font-size: 24rpx;
		font-weight: 500;
		font-family: OPPOSANS;
	}

	.total-text {
		font-size: 24rpx;
		font-weight: 400;
		line-height: 24rpx;
		color: $dark-9;
		margin-left: 8rpx;
	}
}
</style>
